var fs = require('fs')

// json文件目录
var newFilePath = "./statistic/04_ideas/new.json"
var displayFilePath = "./statistic/04_ideas/display.json"
var medicineFilePath = "./statistic/04_ideas/medicine.json"
var learnFilePath = "./statistic/04_ideas/learn.json"
var emotionFilePath = "./statistic/04_ideas/emotion.json"
var lifeFilePath = "./statistic/04_ideas/life.json"
var gameFilePath = "./statistic/04_ideas/game.json"

const loadData = function(url) {
    var temp = fs.readFileSync(url, 'utf8')
    var temps = JSON.parse(temp)
    return temps
}

var news = {
    data:loadData(newFilePath)
}
var displays = {
    data:loadData(displayFilePath)
}
var medicines = {
    data:loadData(medicineFilePath)
}
var learns = {
    data:loadData(learnFilePath)
}
var emotions = {
    data:loadData(emotionFilePath)
}
var lifes = {
    data:loadData(lifeFilePath)
}
var games = {
    data:loadData(gameFilePath)
}





// 模块导出
// 定义相关函数

var res = {}


res.newAll = function() {
    var contents = news.data
    return contents
}
res.displayAll = function() {
    var contents = displays.data
    return contents
}
res.medicineAll = function() {
    var contents = medicines.data
    return contents
}
res.learnAll = function() {
    var contents = learns.data
    return contents
}
res.emotionAll = function() {
    var contents = emotions.data
    return contents
}
res.lifeAll = function() {
    var contents = lifes.data
    return contents
}
res.gameAll = function() {
    var contents = games.data
    return contents
}


//导出一个对象，可直接引用
module.exports = res
